package com.atguigu.yygh.common.utils;

import javax.servlet.http.HttpServletRequest;

public class AuthContextHolder {

    //根据请求获取token，再获取用户id
    public static Long getUserId(HttpServletRequest request){
        //从request头信息拿到token
        String token = request.getHeader("token");
        //使用jwt工具获取userid
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }

    //根据请求获取token，再获取用户姓名
    public static String getUserName(HttpServletRequest request){
        //从request头信息拿到token
        String token = request.getHeader("token");
        //使用jwt工具获取userid
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}
